package com.jlkf.controller;

import com.jlkf.common.Page;
import com.jlkf.pojo.*;
import com.jlkf.service.DriverService;
import com.platform.server.response.pojo.ReturnData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 司机端
 */
@RestController
@RequestMapping(("/driver"))
public class DriverController {

    @Autowired
    private DriverService driverService;

    //司机端用户信息
    @RequestMapping("/info")
    public Object getUserInfo(Long uid){
        if(uid != null){
            return new ReturnData(driverService.getUserInfo(uid));
        }
        return new ReturnData(1,"Oh oh, no data.");
    }

    //司机端通知
    @RequestMapping("/notice")
    public Object getUserNotices(Long uid, Page page){
        if(uid != null){
            return driverService.getUserNotices(uid,page);
        }
        return new ReturnData(200,"Oh oh, no data.");
    }
    
    //未读统计
    @RequestMapping("notRead")
    public Object notRead(Long uId){
    	return driverService.notRead(uId);
    }

    //修改个人资料提交
    @RequestMapping("/update")
    public Object updateUser(@Validated @RequestBody User user){
        return driverService.updateUser(user);
    }

    //添加银行卡
    @RequestMapping("/addcard")
    public Object addCard(@Validated @RequestBody UserBrank bank){
        return driverService.addCard(bank);
    }

    @RequestMapping("/updatecard")
    public Object updatecard(@RequestBody UserBrank bank){
        return driverService.updatecard(bank);
    }
    
    //我的车辆
    @RequestMapping("/cars")
    public Object getUserCars(Long uid){
        return driverService.getUserCars(uid);
    }

    //评论乘客
    @RequestMapping("/commentPassenger")
    public Object commentPassenger(@Validated @RequestBody StarRemark star){
        return driverService.commentPassenger(star);
    }

    //我的车辆信息
    @RequestMapping("/carInfo")
    public Object carInfo(Long carid){
        if(carid != null){
            return driverService.carInfo(carid);
        }
        return new ReturnData(1,"Oh oh, no data.");
    }

    //评价反馈
    @RequestMapping("/feedback")
    public Object feedback(@Validated @RequestBody SugFeedback feedback){
        return new ReturnData(driverService.feedback(feedback));
    }

    //添加车辆
    @RequestMapping("/addCar")
    public Object addCar(@Validated @RequestBody DriverAccessory car){
        return new ReturnData(driverService.addCar(car));
    }

    //我的提成结算单
    @RequestMapping("/mybill")
    public Object mybill(Long uid,String mark,Integer len){
        if(uid != null && mark !=null && !"".equals(mark)){
            return driverService.mybill(uid,mark,len);
        }
        return new ReturnData(1,"Parameter error");
    }

    //我的提成结算单-月
    @RequestMapping("/monthbill")
    public Object monthbill(Long id){
        if(id != null){
            return new ReturnData(driverService.monthbill(id));
        }
        return new ReturnData(1,"Oh oh, no data.");
    }

    //查询订单表中的数据
    @RequestMapping("/billingDetails")
    public Object billingDetails(String startTime,String endTime,Long driverId,Integer pageNo,Integer pageSize){
    	return driverService.billingDetails(startTime,endTime,driverId,pageNo,pageSize);
    }
    //设置车辆默认
    @RequestMapping("setDefaultVehicle")
    public Object setDefaultVehicle(Long driverId,Long carId,Integer language){
    	return driverService.setDefaultVehicle(driverId,carId,language);
    }
    //设置车辆服务类型
    @RequestMapping("carServiceType")
    public Object carServiceType(Long carId,String serverType,Integer language){
		return driverService.carServiceType(carId, serverType, language);
	}
}
